package edu.nf.utils.handler;

import edu.nf.utils.RowProcessor;
import edu.nf.utils.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;

public class ColumnHandler<T> implements ResultSetHandler<T>{

    private int index;
    private Class<T> clazz;

    public ColumnHandler(int index , Class<T> clazz){
        this.index = index;
        this.clazz = clazz;
    }


    public T handle(ResultSet rs) throws SQLException {
        return rs.next()? RowProcessor.toColumn(rs,index,clazz):null;
    }
}
